package com.ruoyi.web.core.wang.utils;
//Created by sam on 2018/11/26 9:45

public class ResponseUtils {
    public static ResponseBean ok() {
        ResponseBean rb = new ResponseBean();
        rb.setCode(200);
        rb.setMsg("成功");
        return rb;
    }

    public static ResponseBean ok(Object data) {
        ResponseBean obj = new ResponseBean();
        obj.setCode(200);
        obj.setMsg("成功");
        obj.setData(data);
        return obj;
    }

    public static ResponseBean ok(String msg, Object data) {
        ResponseBean obj = new ResponseBean();
        obj.setCode(200);
        obj.setMsg(msg);
        obj.setData(data);
        return obj;
    }

    public static ResponseBean fail() {
        ResponseBean obj = new ResponseBean();
        obj.setCode(-1);
        obj.setMsg("错误");
        return obj;
    }

    public static ResponseBean fail(int code, String msg) {
        ResponseBean obj = new ResponseBean();
        obj.setCode(code);
        obj.setMsg(msg);
        return obj;
    }

    public static ResponseBean fail401() {
        return fail(401, "请登录");
    }

    public static ResponseBean unlogin(){
        return fail401();
    }

    public static ResponseBean fail402() {
        return fail(402, "参数不对");
    }

    public static ResponseBean badArgument(){
        return fail402();
    }

    public static ResponseBean fail403() {
        return fail(403, "参数值不对");
    }

    public static ResponseBean badArgumentValue(){
        return fail403();
    }

    public static ResponseBean fail501() {
        return fail(501, "业务不支持");
    }

    public static ResponseBean unsupport(){
        return fail501();
    }

    public static ResponseBean fail502() {
        return fail(502, "系统内部错误");
    }

    public static ResponseBean serious(){
        return fail502();
    }

}
